package com.example.superoa.model.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.superoa.model.dao.SalaryAccountDao;
import com.example.superoa.model.dao.SalarySubDao;
import com.example.superoa.model.dao.StaffDao;
import com.example.superoa.model.mappers.AccountMapper;
import com.example.superoa.model.pojos.SalaryAccout;
import com.example.superoa.model.pojos.SalarySub;
import com.example.superoa.model.pojos.Staff;

@Service
@Transactional(rollbackFor=Exception.class)
public class SalaryStaffService {
	@Autowired
	private AccountMapper am;
	@Autowired
	private SalaryAccountDao sad;	
	@Autowired
	private StaffDao sd;
	
	@Autowired
	private SalarySubDao subdao;
	
	public void stafft(List<Integer> staff_id) {
		List<Staff> list=new ArrayList<>();
		if(staff_id.size()!=0) {
			for (Integer  idd : staff_id) {
				Staff staff=sd.findById(idd).get();
				list.add(staff);
			}
		}
		Integer id=am.selectID();		
		SalaryAccout salaryAccout=am.selectAccID(id);
		for (Staff staff : list) {
			staff.setSalaryAccout(salaryAccout);
			sd.save(staff);
		}		
	}
}
